package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.dto.EmpQueryParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmpMapper {
    List<Emp> list(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp (username,name,gender,phone,job,salary,image,dept_id,entry_date,create_time,update_time) values " +
            "(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{deptId},#{entryDate},#{createTime},#{updateTime})")
    void insert(Emp emp);

    @Select("select * from emp")
    List<Emp> findAll();

    void delete(List<Integer> ids);

    Emp getInfo(Integer id);

    void update(Emp emp);

    Integer getDeptId(Integer id);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);
}
